package cn.wolf.lbs;

import android.content.Context;
import android.location.Location;
import cn.wolf.base.BaseTask;
import cn.wolf.http.BaseResp;
import cn.wolf.http.HttpCallBack;

/**
 * <h3>定位异步服务</h3>
 * <p>异步进行基站定位，后续可以增加GPS定位到这里。启动异步定位前，需要使用{@link #setParams}方法进行参数设置后再调用。</p>
 */
public class LocationService extends BaseTask<Void, Void, Void> {

	private Context mContext;
	private String action; // broadcast action

	public LocationService(HttpCallBack<BaseResp> iCall, Context context) {
		super(iCall, context);

		mContext = context;
	}

	/**
	 * 设置参数
	 * @param action
	 * 		参数
	 */
	public void setParams(String action) {
		this.action = action;
	}

	@Override
	protected BaseResp doInBackground(Void... params) {
		Location location = LocationUtils.getLocationByNetwork(mContext);
		LocationUtils.sendBroadcast(location, mContext, action);
		return new BaseResp();
	}

}
